﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.IO;

namespace YammerAPI
{
    public class XMLParser<T> where T : YammerApiObject
    {
        public T Parse(string pXML)
        {
            return (T) Deserialize(typeof(T), pXML);
        }

        public static object Deserialize(Type pType, string pXml)
        {
            XmlSerializer serializer = new XmlSerializer(pType);
            using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(pXml)))
                return serializer.Deserialize(stream);
        }
    }
}
